<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="js/1.4.8/angular.js"></script>
    <style type="text/css">
        body {
            font-size: 1.5em;
        }

        .div {
            background-color: #2a6496;
            width: 780px;
            padding: 8px;
            color: #fff;
        }
    </style>
</head>
<body>
===============================myCtrl1==========================================
<div class="div" ng-controller="myCtrl">
    <span>图书ISBN号:{{ISBN}}</span>
    <br>
    <span>当前汇率:{{RATE}}</span>
    <br>
    <br>
</div>
===============================myCtrl2==========================================
<div class="div" ng-controller="myCtrl2">
    <span>图书ISBN号:{{ISBN}}</span>
    <br>
    <span>当前汇率:{{RATE}}</span>
    <br>
    <br>

</div>
<script type="application/javascript">
    var app = angular.module("app", []);

    // constant、value服务返回的都是常量，在控制器中注入这两个服务之后，同样也实例化成
    // 一个服务对象，以对象属性的方式获取常量值。
    // 两者之间区别：使用constant方法创建的服务返回的常量可以被注入到配置函数（config）
    //              中。而value方法创建服务返回的值则不能注入
    app.constant("$constantService", {
                ISBN: '987654321'
            }
    );
    app.value("$valueService",{
        RATE:665
    });

    app.controller("myCtrl", ["$scope", "$constantService","$valueService", function ($scope, $constantService,$valueService) {
        // 重置服务常量的值
        angular.extend($valueService,{
            RATE:700
        });
        angular.extend($constantService,{
            ISBN:'xxx'
        });
        $scope.ISBN = $constantService.ISBN;
        $scope.RATE = $valueService.RATE;
    }]);

    app.controller("myCtrl2", ["$scope", "$constantService","$valueService", function ($scope, $constantService,$valueService) {
        $scope.ISBN = $constantService.ISBN;
        $scope.RATE = $valueService.RATE;
    }]);
</script>
</body>
</html>